/**
 * 
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * 
 */
package org.jiopi.ibean.kernel.context;

import org.jiopi.framework.ControlPanel;
import org.jiopi.ibean.kernel.util.ObjectAccessor;

/**
 * 
 * 反射机制调用对象的快捷工具类
 * 
 * @version 0.1 2010.4.20
 * @since iBeanKernel0.1 2010.4.20
 *
 */
public final class ControlPanelImpl implements ControlPanel {
	
	/**
	 * 封装对象
	 */
	public final Object wrapped ;
	
	public ControlPanelImpl(final Object o){
		if(o == null )throw new NullPointerException();
		this.wrapped = o;
	}
	
	public <T> T variable(String variableName, Class<T> returnType) {
		return ObjectAccessor.variable(wrapped, variableName, returnType);
	}
	
	public <T> T operate(String registerName, Class<T> returnType, Object... args) {
		return ObjectAccessor.method(wrapped, registerName, returnType, args);
	}

	public <T> T operateStrict(String registerName, Class<T> returnType,Object[] parameterTypes, Object... args) {
		return ObjectAccessor.strictMethod(wrapped, registerName, returnType, parameterTypes, args);
	}
	
	@Override
	public int hashCode(){
		return wrapped.hashCode();
	}
	
	@Override
	public boolean equals(Object obj){
		return wrapped.equals(obj);
	}
	
	@Override
	public String toString(){
		return wrapped.toString();
	}

}
